import datetime


def try_except_decorator(func):
    def wrapper(*args, **kwargs):
        try:
            result = func(*args, **kwargs)
            return result
        except Exception as e:
            print(f'[ERROR] - Error: {str(e)}\n')

            with open('logs.txt', 'a') as file:
                dt = datetime.datetime.now()
                file.write(f'{dt} [ERROR] - Error: {str(e)}\n')

    return wrapper
